<?php

	# Includo file di configurazione generale
	require_once("inc/config.inc.php");
	
	# Inizializzo PostgreSQL
	postgresql_connect();

	# Inizializzo Sessioni PostgreSQL
	require_once("inc/postgresql_session.class.php");
	$s = new postgresql_session($DB['link']);
	
	# Garbage collector
	$s->gc();
	
	$query = "SELECT COUNT(*) FROM session";
	$result = pg_query($DB['link'], $query);
	
	$row = pg_fetch_array($result);
	
	$numsess = $row[0];
	$email = trim($_POST['email']);
	
	if(!empty($_POST['send']) && !empty($email)) {
		$fp = fopen("emails.txt", "a");
		flock($fp, LOCK_EX);
		fputs($fp, "[".date("d/m/Y @ H:i:s")."] ".$email);
		flock($fp, LOCK_UN);
		fclose($fp);
		$sent = true;
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="images/favicon.png" rel="shortcut icon"></link>
<title>Latino Systems</title>
<style>
body {
	font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;
}

a:link, a:visited {
	color: #600;
	background-color: transparent;
	text-decoration: none;
}

a:hover, a:active {
	color: #333;
	text-decoration: underline;
}

#logo {
	text-align:center;
	margin-bottom:20px;
}
#sessionid {
	text-align:center;
}
#navcontainer {
	margin-top:30px;
	text-align:center;
}
#navlist li
{
display: inline;
list-style-type: none;
padding-right: 20px;
}
</style>
</head>
<body>
<div id="logo"><img src="images/latino_logo.png" /></div>
<div style="text-align:center; margin-bottom:30px">Sistemi di raccomandazione di oggetti multimediali</div>
<div style="text-align:center; margin-bottom:30px"><?php if(!$sent) { ?>Se sei curioso, lascia il tuo indirizzo email e sarai avvisato quando sar&agrave; disponibile la prima versione pubblica di Latino!<br /><br /><form method="POST">

	<table align="center">
		<tr>

		  <td>Email:</td>

		  <td>

		    <input type="text" name="email" id="email" />

		  </td>

	  </tr>

		<tr>

		  <td>&nbsp;</td>

		  <td><input name="send" type="hidden" id="send" value="yes" /></td>

		  </tr>

		<tr>

		  <td>&nbsp;</td>

		  <td>

		    <input type="submit" name="submit" id="submit" value="Invia!" />

		    </td>

		  </tr>

	</table>

</form><?php } else {?><strong>Ti ringraziamo per l'interessamento. Sarai aggiornato a breve!</strong><?php } ?></div>
<div id="sessionid">Sessioni di visita attive: <?php echo $numsess; ?></div>
<div id="navcontainer">
<ul id="navlist">
<li><a href="http://wpage.unina.it/malbanes/labadam/">LaBaDaM</a></li>
<li><a href="http://www.unina.it">UniNa</a></li>
<li><a href="mailto:gianluca.cacace@gmail.com">Contatti</a></li>
</ul>
</div>
</body>
</html>
